package main

import (
	"fmt"
	"strings"
)

func simplifyPath(path string) string {
	pathArray := strings.Split(path, "/")
	var stack []string
	for _, s := range pathArray {
		if s == ".." {
			if len(stack) > 0 {
				stack = stack[0 : len(stack)-1]
			}
		} else if s != "." && len(s) > 0 {
			stack = append(stack, s)
		}
	}
	return "/" + strings.Join(stack, "/")
}

func main() {
	fmt.Println(simplifyPath("/home//foo"))
	fmt.Println(simplifyPath("/a/./b/../../c/"))
}
